package com.huika.dealontop.control.shops.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.huika.dealontop.R;
import com.huika.dealontop.control.base.BaseAda;
import com.huika.dealontop.support.domain.ProductDetailsBean;
import com.huika.dealontop.utils.UIUtils;

import java.util.List;

/**
 * Author: Victor Wu <br/>
 * Email: victor-wu*foxmail.com <br/>
 * Time: 2016/1/13 10:43 <br/>
 * Description: 团购套餐列表适配器
 */
public class PackageAdapter extends BaseAda<ProductDetailsBean.PackageSelectBean> {

    public PackageAdapter(Context context) {
        super(context);
    }

    public List<ProductDetailsBean.PackageSelectBean> getGroup() {
        return group;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder vh;
        if (view == null) {
            view = View.inflate(UIUtils.getContext(), R.layout.item_package_list, null);
            vh = new ViewHolder(view);
            view.setTag(vh);
        } else {
            vh = (ViewHolder) view.getTag();
        }
        ProductDetailsBean.PackageSelectBean bean = getItem(i);
        vh.tv_name.setText(bean.getSkuName());
        vh.checkBox.setBackgroundResource(bean.isSelect ? R.mipmap.tick_language : R.color.color_transparent);
        return view;
    }


    class ViewHolder {
        public TextView tv_name;
        public ImageView checkBox;

        public ViewHolder(View view) {
            tv_name = (TextView) view.findViewById(R.id.tv_select_name);
            checkBox = (ImageView) view.findViewById(R.id.iv_select_icon);
        }
    }
}